package seminar.evaluate;

import seminar.LectureEvent;
import seminar.Semester;

/**
 * Evaluate semester's breaks
 * @author Johannes Degler
 *
 */
public class BreaksEvaluator implements IEvaluator {

	private int calcBreak(final int breakCount) {
		switch(breakCount){
		case 1: //One slot break
			return -10;
		case 2: //Two slot break
			return -20;
		case 3: //Three slot break
			return -40;
		case 4: //Four slot break
			return -100;
		case 5: //Five slot break
			return -200;
		case 6: //Six slot break == No lectures this day
			return 50;
		default:
			return 0;
		}
	}

	@Override
	public int getPoints(final Semester semester) {
		int points = 0;

		for(int day = 0; day < 5; day++){
			int breakCount = 0;
			boolean passedNonBreak = false;
			for(int slot = 0; slot < 6; slot++){
				final LectureEvent event = semester.getEvents()[day][slot];

				if(passedNonBreak){
					if(event == null)
						breakCount++;
					else{
						points += this.calcBreak(breakCount);
						breakCount = 0;
					}
				}
				else if(event != null)
					passedNonBreak = true;
			}
		}

		return points;
	}

}
